﻿<navCtl:Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  xmlns:navCtl="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
  xmlns:fx="clr-namespace:BookClub.Core"
  xmlns:fxCtl="clr-namespace:BookClub.Controls"
  xmlns:local="clr-namespace:BookClub.Pages"
  x:Class="BookClub.Pages.Members" 
  mc:Ignorable="d"
  d:DataContext="{d:DesignInstance Type=local:MembersModel, IsDesignTimeCreatable=False}"
  d:DesignWidth="800" d:DesignHeight="600"
  Title="Members">
  <navCtl:Page.Resources>
    <fx:Command x:Key="addCommand" Method="AddMember" />
    <fx:Command x:Key="cancelCommand" Method="CancelAddMember" />
  </navCtl:Page.Resources>
  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="*" />
      <RowDefinition Height="10" />
      <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <ListBox BorderThickness="0"
      ItemsSource="{Binding Members}"
      ScrollViewer.HorizontalScrollBarVisibility="Disabled"
      ScrollViewer.VerticalScrollBarVisibility="Auto">
      <ListBox.ItemTemplate>
        <DataTemplate>
          <Grid Margin="0,0,0,5">
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="450" />
              <ColumnDefinition Width="200" />
              <ColumnDefinition Width="150" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
              <RowDefinition Height="Auto" />
              <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <TextBlock Style="{StaticResource listMainText}" Text="{Binding MemberName}" />
            <TextBlock Style="{StaticResource listText}" Grid.Column="1"
              Text="{Binding MemberAlias}" />
            <TextBlock Style="{StaticResource listText}" Grid.Column="2" HorizontalAlignment="Right"
              TextAlignment="Right"
              Text="{Binding MemberOffice}" />
          </Grid>
        </DataTemplate>
      </ListBox.ItemTemplate>
    </ListBox>
    
    <Grid Grid.Row="2" DataContext="{Binding NewMember}">
      <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition Height="6" />
        <RowDefinition />
        <RowDefinition Height="6" />
        <RowDefinition />
        <RowDefinition Height="6" />
        <RowDefinition />
      </Grid.RowDefinitions>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="10" />
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="10" />
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="*" />
      </Grid.ColumnDefinitions>
      <TextBlock Grid.ColumnSpan="9" Style="{StaticResource labelHeading}" Text="Add New Member" />
      <TextBlock Grid.Row="2" Style="{StaticResource label}" Text="Name:" />
      <TextBox x:Name="nameTextBox" Grid.Column="1" Grid.Row="2" Width="150"
        Text="{Binding MemberName, Mode=TwoWay}" />
      <TextBlock Grid.Column="3" Grid.Row="2" Style="{StaticResource label}" Text="Alias:" />
      <TextBox x:Name="aliasTextBox" Grid.Column="4" Grid.Row="2" Width="150"
        Text="{Binding MemberAlias, Mode=TwoWay}" />
      <TextBlock Grid.Row="2" Grid.Column="6" Style="{StaticResource label}" Text="Password:" />
      <PasswordBox x:Name="passwordBox" Grid.Column="7" Grid.Row="2" Width="150"
        Password="{Binding Password, Mode=TwoWay}" />
      <TextBlock Grid.Row="4" Style="{StaticResource label}" Text="Office:" />
      <TextBox x:Name="officeTextBox" Grid.Column="1" Grid.Row="4" Width="150"
        Text="{Binding MemberOffice, Mode=TwoWay}" />
      <StackPanel Orientation="Horizontal" Grid.Row="6" Grid.ColumnSpan="8" HorizontalAlignment="Right">
        <Button x:Name="cancelButton" Content="Cancel"
          Command="{StaticResource cancelCommand}" />
        <Button x:Name="addButton" Content="Add" Margin="6,0,0,0"
          Command="{StaticResource addCommand}" />
      </StackPanel>
    </Grid>
  </Grid>
</navCtl:Page>
